package com.campus.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 配送员进度枚举
 */
@Getter
@AllArgsConstructor
public enum DeliveryProcessEnum {

    /**
     * 待抢单
     */
    PENDING_GRAB(0, "待抢单"),

    /**
     * 待取餐
     */
    PENDING_PICKUP(1, "待取餐"),

    /**
     * 配送中
     */
    DELIVERING(2, "配送中"),

    /**
     * 已送达
     */
    DELIVERED(3, "已送达");

    @EnumValue
    @JsonValue
    private final Integer value;
    private final String text;

    public static String getTextByValue(Integer value) {
        for (DeliveryProcessEnum status : values()) {
            if (status.getValue().equals(value)) {
                return status.getText();
            }
        }
        return null;
    }

    public static DeliveryProcessEnum getByValue(Integer value) {
        for (DeliveryProcessEnum temp : DeliveryProcessEnum.values()) {
            if (temp.getValue().equals(value)) {
                return temp;
            }
        }
        return null;
    }
}